package com.yalpuz;

import com.yalpuz.entity.User;
import com.yalpuz.service.UserService;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.HashMap;

@Controller
public class UserController {

	@Resource
	private UserService userService;

	@Transactional()
	@RequestMapping
	@ResponseBody
	public Object index() {
		User user = new User();
		user.setName("ADL");
		user.setEmail("303253183@qq.com");
//		entityManager.getTransaction().begin();
		userService.save(user);
//		entityManager.getTransaction().commit();
		return new HashMap<>();
	}
}
